#include"MySQL.hpp"
using namespace ns_mysql;

const std::string host = "127.0.0.1";
const std::string user = "con";
const std::string pass = "123456";
const std::string db = "lhd_work_db";

const int port = 3306;

int main()
{
    MySQL my;
    if(!my.ConnectMysql(host,user,pass,db,port))
    {
        std::cerr<<"连接MySQL失败"<<std::endl;
        return -1;
    }
    // std::string sql = R"(update user set name='李四' where id = 1)";
    std::string sql = R"(select* from user)";
    std::vector<MYSQL_ROW> res;
    int filed = 0;
    my.Query(sql,&res,&filed);

    if(res.size() == 0) 
    {
        std::cout<<"结果集为空"<<std::endl;
        return -2;
    }
    for(int i = 0;i<res.size();i++)
    {
        for(int j = 0;j<filed;j++)
        {
            std::cout<<res[i][j]<<"\t";
        }
        std::cout<<"\n";
    }
    return 0;
}
